<?php

class Setor extends DataMapper {

	var $error_prefix = '<div class="alert alert-danger" role="alert">';
    var $error_suffix = '</div>';
	
    var $table = 'setores';
	
	var $has_one = array("secretaria");
	
	var $validation = array(
		'nomesetor' => array(
			'label' => 'Nome Setor',
			'rules' => array('required')
		),
		'secretaria_id' => array(
			'label' => 'Secretaria',
			'rules' => array('required')
		),
		'tag' => array(
			'label' => 'Tag de Busca',
			'rules' => array('required')
		)
	);

    function __construct($id = NULL)
    {
        parent::__construct($id);
    }
	
	public function consultaSetor(){
	
		$setor = new Setor();
		$setor = $setor->include_related("secretaria")->order_by("secretarias.sigla asc")->get();
		//echo $setor->check_last_query();
		$aux = array();
		//$aux["0"] = "-- TODOS --";
		foreach($setor as $s){
			$aux[$s->id ] = $s->secretaria_sigla.' - '.$s->nomesetor;
		}
	
		return $aux;
	
	}
	
}

/* End of file local.php */
/* Location: ./application/models/local.php */
